function updataInfo() {
	layui.use('layer', function() {
		var layer = layui.layer;
		layer.open({
			type: 1,
			title: '编辑基本资料',
			maxmin: false,
			shadeClose: true,
			content: $('#here'),
		});
	});
}

function updataImg() {
	layer.open({
		type: 1,
		title: '修改头像',
		content: $('#gtx'),
	});
}

function choiseImg(file) {
	var tempStr = "";
	if(file.files && file.files[0]) {
		var reader = new FileReader();
		reader.onload = function(evt) {
			tempStr = '<div class="per_ingtx" onmousemove="gettximg()"><img src="' + evt.target.result + '" width="300px" height="280px"  alt=""/>';
			tempStr += '<div class="per_cutimg"></div></div>';
			tempStr += '<div  style="width:100%;text-align:center;margin-top:20px"><input type="button" value="确定" style="padding:5px 10px;margin-right:20px;background:#ffffff"><input type="button" value="重新上传" style="padding:5px 10px;background:#ffffff"></div>';
			$('#gtx').html(tempStr);
		}
		reader.readAsDataURL(file.files[0]);
	}
}

function gettximg() {
	event = event || window.event;

	var move = false;
	var disX, disY;
	$(".per_cutimg").click(function() {

	}).mousedown(function(e) {
	  
		move = true;
		disX = event.pageX - $(".per_cutimg").get(0).offsetWidth / 2 - $(".per_ingtx").offset().left;
		disY = event.pageY - $(".per_cutimg").get(0).offsetHeight / 2 - $(".per_ingtx").offset().top;
	});

	$(".per_cutimg").mousemove(function(e) {
		if(move) {
			var distenceMaxX = $(".per_ingtx").get(0).offsetWidth - $(".per_cutimg").get(0).offsetWidth;
			var distenceMaxY = $(".per_ingtx").get(0).offsetHeight - $(".per_cutimg").get(0).offsetHeight;

			var distenceMinX = 0;
			var distenceMinY = 0;
			
			disX = event.pageX - $(".per_cutimg").get(0).offsetWidth / 2 - $(".per_ingtx").offset().left;
		    disY = event.pageY - $(".per_cutimg").get(0).offsetHeight / 2 - $(".per_ingtx").offset().top;

			if(disX < distenceMinX) {
				disX = distenceMinX;
			} else if(disX >= distenceMaxX) {
				disX = distenceMaxX
			}
			if(disY < distenceMinY) {
				disY = distenceMinY;
			} else if(disY >= distenceMaxY) {
				disY = distenceMaxY;
			}

			$(".per_cutimg").css("left", disX + "px");
			$(".per_cutimg").css("top", disY + "px");
		}
	}).mouseup(function() {
		move = false;
	
	});

	/*var disX = event.pageX - $(".per_cutimg").get(0).offsetWidth / 2 - $(".per_ingtx").offset().left;
	var disY = event.pageY - $(".per_cutimg").get(0).offsetHeight / 2 - $(".per_ingtx").offset().top;

	var distenceMaxX = $(".per_ingtx").get(0).offsetWidth - $(".per_cutimg").get(0).offsetWidth;
	var distenceMaxY = $(".per_ingtx").get(0).offsetHeight - $(".per_cutimg").get(0).offsetHeight;

	var distenceMinX = 0;
	var distenceMinY = 0;

	if(disX < distenceMinX) {
		disX = distenceMinX;
	} else if(disX >= distenceMaxX) {
		disX = distenceMaxX
	}
	if(disY < distenceMinY) {
		disY = distenceMinY;
	} else if(disY >= distenceMaxY) {
		disY = distenceMaxY;
	}

	$(".per_cutimg").css("left", disX + "px");
	$(".per_cutimg").css("top", disY + "px");*/
}